import Vue from 'vue'
import './plugins/axios'
import App from './App.vue'
import router from './router'
import store from './store'
import './plugins/element.js'
//全局应用这两个样式
import "./assets/css/me.css";
import "./assets/css/style.css";


import ElementUI from "element-ui"
import 'element-ui/lib/theme-chalk/index.css'
import VueParticles from 'vue-particles'
import mavonEditor from 'mavon-editor'
import 'mavon-editor/dist/css/index.css'
// use
Vue.use(mavonEditor)
Vue.use(VueParticles)
Vue.use(ElementUI)
Vue.config.productionTip = false

router.beforeEach((to, from, next) => {
  //判断路由是否需要登录
  if(to.meta.requireAuth){ //需要验证 
	if(sessionStorage.getItem("user_login")==1){ //user_login表示用户登录状态
	    // console.log(store.state)
		//把sessionStorage中的数据保存到vuex中
		store.commit("addUser",sessionStorage.getItem("user_id"),"");
		next(); //放行  
	}else{//用户没有登录
		next({path:"/"}) //返回登录界面
	}  
  }else{//不需要验证
	next(); //放行  
  }
});

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
